<?php

namespace app\admin\command;

use fast\Form;
use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Db;
use think\Exception;
use think\exception\ErrorException;
use think\Lang;
use think\Loader;


class Article extends Command
{
   

    protected function configure()
    {
        $this
            ->setName('article')
            ->setDescription('move article sql');
    }

    protected function execute(Input $input, Output $output)
    {
    	 $list = Db::name('article')->select();
		 foreach($list as $v)
		 {  $data=[];
		    $new =[];
		 	$data['title']=$v['title'];
			$data['channel_id']=$v['c_id'];
			$data['model_id']=1;
			$data['description']=$v['source'];
			$data['views']=$v['click'];
			$data['publishtime']=$v['add_at'];
			$data['createtime']=$v['add_at'];
			$data['updatetime']=$v['update_at'];
			$id = Db::name('cms_archives')->insertGetId($data);
			if($id)
			{
				$new['id']=$id;
				$new['author']=$v['author'];
				$new['content']=$v['content'];
				Db::name('cms_addonnews')->insert($new);	
				$output->info('success');			
			}		
		 } 
	}
       
}
